package com.example.mrzhou.lvmm.model.impl;

import com.example.mrzhou.lvmm.api.HomeService;
import com.example.mrzhou.lvmm.api.RetroManager;
import com.example.mrzhou.lvmm.entity.home.HomeBanner;
import com.example.mrzhou.lvmm.entity.home.HomeContent;
import com.example.mrzhou.lvmm.entity.home.HomeTitle;
import com.example.mrzhou.lvmm.model.IHomeModel;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Mr.zhou on 2016/10/28.
 */

public class HomeModelImpl implements IHomeModel {

    @Override
    public void getHomeTitle(Subscriber<HomeTitle> subscriber) {
        RetroManager.getInstance(HomeService.BASE_URL).getHomeService().getHomeTitle()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }

    @Override
    public void getHomeContent(String back_word1, String back_word2, Long time, Subscriber<HomeContent> subscriber) {
        RetroManager.getInstance(HomeService.BASE_URL).getHomeService().getHomeContent(back_word1,back_word2,time)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }

    @Override
    public void getHomeBanner(Subscriber<HomeBanner> subscriber) {
        RetroManager.getInstance(HomeService.BASE_URL).getHomeService().getHomeBanner()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }
}
